/*
 * @FileDescription: vue项目配置文件
 * @Author: zsf
 * @Date: 2021-03-26 07:40:46
 * @LastEditors: zsf
 * @LastEditTime: 2021-03-29 22:02:47
 */
const path = require('path');
function resolve (dir) {
  return path.join(__dirname, dir)
}
module.exports = {
  // 选项...
  publicPath: process.env.NODE_ENV === 'production' ? './' : './',
  devServer: {
    port: 8080,
    proxy: {
      '/api': {
        target: process.env.VUE_APP_API_BASE_URL,
        ws: false,
        changeOrigin: true,
        pathRewrite: {
          '^/api': '' // 需要rewrite的,
        }
      }
    }
  },
  chainWebpack: (config)=>{
    //修改文件引入自定义路径
    config.resolve.alias
    .set('@', resolve('src'))
    .set('api', resolve('src/api'))
    .set('common', resolve('src/common'))
    .set('utils', resolve('src/utils'))
    .set('views', resolve('src/views'))
    .set('components', resolve('src/components'))
    .set('assets', resolve('src/assets'))
  },
  css: {
    loaderOptions: {
      less: {
        modifyVars: {
          // less 全局变量
          'primary-color': '#1890FF',
          'layout-color': '#1890FF',
          'border-radius-base': '2px'
        },
        // DO NOT REMOVE THIS LINE
        javascriptEnabled: true
      }
    }
  },
}